const { Sequelize } = require("sequelize");
const { DB } = require("./config/config.default");

// 初始化 Sequelize 实例
const sequelize = new Sequelize(DB.DATABASE, DB.USER, DB.PASSWORD, {
    host: DB.HOST,
    dialect: DB.DIALECT,
});

// 测试数据库连接
sequelize
    .authenticate()
    .then(() => console.log("Database connected..."))
    .catch((err) => console.log("Error: " + err));

// sequelize
//     .sync({ alter: true })
//     .then(() => {
//         console.log("Database & tables created!");
//     })
//     .catch((err) => console.error("Error creating tables:", err));

module.exports = sequelize;
